package com.lagou;



import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


public class FileMapper extends Mapper<LongWritable, Text, FileBean, NullWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        FileBean bean = new FileBean();
        //读取文件数据 一行执行一个map方法 文件数据只有一列 因此无需split
        String str = value.toString();
        bean.setId(1);
        bean.setValue(Integer.parseInt(str));
        context.write(bean,NullWritable.get());
    }

    public void close() throws IOException {

    }

    public void configure(JobConf jobConf) {

    }
}
